﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using l1cs.server.templates;
using l1cs.server.serverpackets;
using l1cs.server.datatables;
using l1cs.server.utils;
using System.Collections;

namespace l1cs.server.model.Instance
{
    public class L1ScarecrowInstance : L1NpcInstance
    {
        private static Logger _log = Logger.getLogger( typeof( L1ScarecrowInstance ).FullName );

        public L1ScarecrowInstance( L1Npc template ) : base( template ) { }

        public override void onAction( L1PcInstance player )
        {
            L1Attack attack = new L1Attack( player, this );
            if ( attack.calcHit() )
            {
                if ( player.getLevel() < 5 )
                { // ＬＶ制限もうける場合はここを変更
                    ArrayList targetList = new ArrayList();

                    targetList.Add( player );
                    List<int> hateList = new List<int>();
                    hateList.Add( 1 );
                    CalcExp.calcExp( player, getId(), targetList, hateList, getExp() );
                }
                if ( getHeading() < 7 )
                { // 今の向きを取得
                    setHeading( getHeading() + 1 ); // 今の向きを設定
                }
                else
                {
                    setHeading( 0 ); // 今の向きが7 以上になると今の向きを0に戻す
                }
                broadcastPacket( new S_ChangeHeading( this ) ); // 向きの変更
            }
            attack.action();
        }

        public override void onTalkAction( L1PcInstance l1pcinstance ) { }

        public void onFinalAction() { }

        public void doFinalAction() { }
    }
}
